import { Component, OnInit } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd/message';
import { CommonService } from '../../../../services-common/common.service';
import { ActivatedRoute } from '@angular/router';
import { defalutImg } from '../../../../comm';
import { UnionPayManageService } from '../unionPay-manage.service';

@Component({
  selector: 'app-cooperation-developer-infos',
  templateUrl: './cooperation-developer-infos.component.html',
  styleUrls: ['./cooperation-developer-infos.component.scss']
})
export class CooperationDeveloperInfosComponent implements OnInit {

  routeParams: any = {};
  fallback = defalutImg;
  detailsData: any = {};

  constructor(
    private msg: NzMessageService,
    private commonService: CommonService,
    private activatedRoute: ActivatedRoute,
    private services: UnionPayManageService
  ) {
    activatedRoute.queryParams.subscribe((res: any) => {
      this.routeParams = res || {};
    })
  }

  ngOnInit(): void {
    this.loadDetailsData();
  }

  async loadDetailsData() {
    const msgId = this.msg.loading('数据加载中..', { nzDuration: 0 }).messageId;
    const {code, data, message}: any = await this.services.getDeveloperDetails(this.routeParams.id);
    this.msg.remove(msgId);

    if (code === 0) {
      this.detailsData = data || {};
    } else {
      this.msg.error(message);
    }
  }
}
